﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Showroom.BLL;

namespace ShowroomMobile
{
    public partial class CollectionDetails : System.Web.UI.Page
    {
        private int ProductID
        {
            get
            {
                return string.IsNullOrEmpty(Request["id"]) ? 0 : Convert.ToInt32(Request["id"]);
            }
        }

        protected string FacebookCommentLink
        {
            get
            {
                return Request.Url.ToString();
            }
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                View_Products prod = View_Products.GetByProductID(ProductID);
                if (prod.RowCount < 0)
                {
                    Response.Redirect("~/404.aspx"); return;
                }
                //lblProductName.Text = prod.s_Name;
                //lblProductDetail.Text = prod.s_Description;
                Page.Title = prod.s_Name;

                //Load image
                ProductImages pImgs = ProductImages.GetByProductID(prod.ID);
                rptImageThumb.DataSource = pImgs.DefaultView;
                rptImageThumb.DataBind();
                rptImageMain.DataSource = pImgs.DefaultView;
                rptImageMain.DataBind();

                lblProductName.Text = prod.s_Name;
                lblProductDetail.Text = prod.s_Description;
                lblPrice.Text = (string.IsNullOrEmpty(prod.s_Price) || prod.Price == 0) ? "" : String.Format("{0:C}", prod.Price);
            }
        }
    }
}